package com.jader.fragment;

import java.util.ArrayList;
import java.util.List;

import com.zlp.jader.R;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;


public class BeJudgeFragment extends Fragment {
	// List<Order> list = new ArrayList<Order>();
	List<String> list = new ArrayList<String>();
	ListView BeJudgeListView;
	View BeJudgeView;
	ArrayAdapter<String> adapter;

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		initData();
	}

	private void initData() {
		list.add("推荐一");
		list.add("推荐二");
		list.add("推荐三");
		list.add("推荐四");
		list.add("推荐五");
		list.add("推荐六");
		adapter = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, list);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		BeJudgeView = inflater.inflate(R.layout.fragment_bejudge, null);
		initViews();
		return BeJudgeView;
	}

	/**
	 * 初始化视图
	 */
	private void initViews() {
		BeJudgeListView = (ListView) BeJudgeView
				.findViewById(R.id.BeJude_ListView);
		BeJudgeListView.setAdapter(adapter);
		BeJudgeListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				String text = list.get(position);
				Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
			}
		});
	}
}
